﻿using HCQ2_Common.SQL;
using HCQ2_IDAL;
using HCQ2_Model.VRDD.InputDto._20220627;
using HCQ2_Model.VRDD.OutputDto._20220627;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HCQ2_DAL_MSSQL
{
    public partial class T_VRTotalScoreDetailDAL : IT_VRTotalScoreDetailDAL
    {
        public List<OutputGetUserPointsList> GetUserPointsList(InputGetUserPointsList param)
        {
            sb.Clear();
            
            sb.Append($@"select u.user_id as userid,u.user_name as userName,u.user_phone as userPhone,itemType as dictCode,
            dictName=(select code_name from T_ItemCodeMenum where code_value=itemType),inGold as income,outGold
            from T_VRTotalScoreDetail  tsd left join T_User u on tsd.user_id=u.user_id where tsd.userid='{param.userid}' and CONVERT(date,createDate) between '{param.StartDate}' and '{param.EndDate}'");
            if (!string.IsNullOrEmpty(param.proType))
            {
                sb.Append($@" and proType='{param.proType}'");
            }
            if (!string.IsNullOrEmpty(param.type))
            {
                sb.Append($@" and itemType='{param.type}'");

            }
                return SqlHelper.ExecuteList<OutputGetUserPointsList>(sb.ToString());
        }
    }
}
